<template>
  <section class="container" >
    <div class="title">
      <p>最新时尚设计和潮流趋势，助你紧跟服装资讯的前沿</p>
    </div>
    <div class="topMenu flex flex-js-c">
      <template v-for="(item, index) in newsModule.topMenu" :key="index">
        <div @click="newsModule.checkMenu(index)" class="menu" :class="{'menu-active':newsModule.isActive[index]}">{{item}}</div>
      </template>
    </div>
    <div class="news">
      <div class="news-main">
        <template v-for="(item, index) in newsModule.FashionInformation">
          <div>
            <div @click="newsModule.toDetails(item.id)">
                        <img :src="item.banner[0]" alt="">
            </div>
            <div class="item-title">
              <p>
                {{item.title}}
              </p>
            </div>
            <div class="item-date">
              <p>
                {{item.createTime}}
              </p>
            </div>
          </div>

        </template>
      </div>
    </div>

<!--    {{ $t('header.home') }}-->
<!--    <div-->
<!--        class="demo position-relative"-->
<!--        style="height: 500px; width: 500px;background-color: red"-->
<!--        v-permissionCover="['1','2', '3']"-->
<!--    >-->
<!--      2131-->
<!--    </div>-->
<!--    <button @click="handle">提示信息</button>-->
<!--    <svg-icon name="pass"/>-->
<!--    <button @click="C">切换语言</button>-->
  </section>
</template>

<script lang="ts">
  import { defineComponent, ref, reactive, toRaw } from 'vue';
  import { getApp } from '@/common/hooks';
  import { Messages } from '@/components/Warm/Popup';
  import { Language } from '@/common/lang';

  export default defineComponent({
    name: "news",
    components: {

    },
    data() {
      return {

      }
    },
    mounted() {
      this.newsModule.initNewsData(0);
    },
    setup() {
      const { Router } = getApp(['Router']);
      const { proxy } = getApp(["Vm"]).Vm;
      /* 新闻模块 */
      const newsModule = reactive({
        /*跳转详情*/
        toDetails: function (newsId) {
          Router!.push({ name: 'newsDetails', query: { newsId: newsId }, replace: true });
        },
        /*新闻类型选择*/
        isActive: [true, false, false, false,],
        /**
         * 切换新闻类型
         * @param menuIndex
         */
        checkMenu: function (menuIndex: number) {
          this.isActive.forEach( (item, index) => {
            this.isActive[index] = false;
          });
          this.isActive[menuIndex] = true;
          newsModule.initNewsData(menuIndex);
        },
        /*初始化新闻数据*/
        initNewsData: async function (index) {
          await getApp().System.News?.initNewsMessage(index).then((res) =>{
            newsModule.FashionInformation = res;
          } )


        },
        /*新闻类型菜单*/
        topMenu: [ "时尚趋势", "行业新闻", "服装设计", "时尚活动"],
        /*当前新闻类型数据*/
        FashionInformation: [
          // {
          //   InformationType: "时尚趋势",
          //   InformationItems:
          //       {
          //         itemImageUrl: "@assets/images/fashionInformationItem01.png.svg",
          //         itemTitle: "资深时尚导师一对一招生会",
          //         date: "2024-1-16 17:31:38"
          //       },
          // },
          // {
          //   InformationType: "",
          //   InformationItems:
          //       {
          //         itemImageUrl: "@assets/images/fashionInformationItem01.png.svg",
          //         itemTitle: "资深时尚导师一对一招生会",
          //         date: "2024-1-16 17:31:38"
          //       },
          // },
          // {
          //   InformationType: "",
          //   InformationItems:
          //       {
          //         itemImageUrl: "@assets/images/fashionInformationItem01.png.svg",
          //         itemTitle: "资深时尚导师一对一招生会",
          //         date: "2024-1-16 17:31:38"
          //       },
          // },
          // {
          //   InformationType: "",
          //   InformationItems:
          //       {
          //         itemImageUrl: "@assets/images/fashionInformationItem01.png.svg",
          //         itemTitle: "资深时尚导师一对一招生会",
          //         date: "2024-1-16 17:31:38"
          //       },
          // },
          // {
          //   InformationType: "",
          //   InformationItems:
          //       {
          //         itemImageUrl: "@assets/images/fashionInformationItem01.png.svg",
          //         itemTitle: "资深时尚导师一对一招生会",
          //         date: "2024-1-16 17:31:38"
          //       },
          // },
          // {
          //   InformationType: "",
          //   InformationItems:
          //       {
          //         itemImageUrl: "@assets/images/fashionInformationItem01.png.svg",
          //         itemTitle: "资深时尚导师一对一招生会",
          //         date: "2024-1-16 17:31:38"
          //       },
          // },
          // {
          //   InformationType: "",
          //   InformationItems:
          //       {
          //         itemImageUrl: "@assets/images/fashionInformationItem01.png.svg",
          //         itemTitle: "资深时尚导师一对一招生会",
          //         date: "2024-1-16 17:31:38"
          //       },
          // },
        ]

      })

      return {
        newsModule
      }
    }
  });
</script>

<style lang="scss" scoped>
.container {
  padding-top: 100Px;
  margin-bottom: 150Px;
}
.title {
  width: 100%;
  color: $color-main;
  text-align: center;
  font-family: "PingFang SC";
  font-size: $-pc-font-size-xl;
  font-style: normal;
  font-weight: 400;
  line-height: $-pc-font-size-xl; /* 92.308% */
}
.topMenu {
  div {
    margin-top: 50Px;
    margin-bottom: 50Px;
    margin-right: 50Px;
  }
  .menu-active {
    border-bottom: black 2Px solid;
    color: $color-main !important;
  }
  .menu {
    cursor: pointer;
    color: #999;
    text-align: center;
    font-family: "PingFang SC";
    font-size: 16Px;
    font-style: normal;
    font-weight: 400;
    line-height: 24Px; /* 150% */
  }
}

.news {
  padding-left: 240Px;
  padding-right: 240Px;
}
.news-main {
  display: grid;
  grid-template-columns: 32% 32% 32%;
  grid-gap: 3%;
  img {
    width: 100%;
    height: 100%;
    margin-bottom: 25Px;
  }
  .item-title {
    height: 20Px;
    color: $color-main;
    font-family: "PingFang SC";
    font-size: $-pc-font-size-sm;
    font-style: normal;
    font-weight: 400;
    line-height: 24Px; /* 150% */
    margin-bottom: 10Px;
  }
  .item-date{
    color: #999;
    font-family: "PingFang SC";
    font-size: 14Px;
    font-style: normal;
    font-weight: 400;
    line-height: 24Px; /* 171.429% */
  }

}
</style>
